﻿using AutoMapper;
using Modules;
using PmSoft;
using System.ComponentModel.DataAnnotations;

namespace ManagementApi.Models.System;

/// <summary>
/// 预警记录表
///</summary>
public class SysEarlyWarningEditForm
{
    /// <summary>
    /// 主键 
    ///</summary>
     [Display(Name="主键")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int Id { get; set; }
    /// <summary>
    /// 编号 
    ///</summary>
     [Display(Name="编号")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string Code { get; set; }
    /// <summary>
    /// 租户 
    ///</summary>
     [Display(Name="租户")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int Tenant { get; set; }
    /// <summary>
    /// 对象表id 
    ///</summary>
     [Display(Name="对象表id")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string ObjectId { get; set; }
    /// <summary>
    /// 预警类型 
    ///</summary>
     [Display(Name="预警类型")]
     [Required(ErrorMessage = "{0}不能为空")]
     public int WarningType { get; set; }
    /// <summary>
    /// 是否需要推送 
    ///</summary>
     [Display(Name="是否需要推送")]
     [Required(ErrorMessage = "{0}不能为空")]
     public bool HasPush { get; set; }
    /// <summary>
    /// 预警内容 
    ///</summary>
     [Display(Name="预警内容")]
     [Required(ErrorMessage = "{0}不能为空")]
     public string Remark { get; set; }
    /// <summary>
    /// 预警时间 
    ///</summary>
     [Display(Name="预警时间")]
     [Required(ErrorMessage = "{0}不能为空")]
     public DateTime CreateTime { get; set; }
    /// <summary>
    /// 推送时间（has_push 为true时必填） 
    ///</summary>
     [Display(Name="推送时间（has_push 为true时必填）")]
     public DateTime? PushTime { get; set; }

#region 扩展字段

//这里自行增加扩展字段，如 项目名称

#endregion
}

public static class SysEarlyWarningExtensions
{
  public static SysEarlyWarningEditForm AsForm(this SysEarlyWarning entity)
  {
      SysEarlyWarningEditForm form = new();
      var mapper = ServiceAccessor.GetService<IMapper>();
      mapper.Map(entity, form);
      #region 这里给扩展字段赋值
      #endregion
      return form;
  }
}
